package com.roadjava.rbac.mapper;

import com.roadjava.rbac.bean.entity.SuggestionDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface SuggestionMapper {

    // 添加建议
    @Insert("INSERT INTO suggestion (ResourceID, id, Content) VALUES (#{resourceid}, #{id}, #{content})")
    void addSuggestion(SuggestionDO suggestion);

    // 更新建议
    @Update("UPDATE suggestion SET ResourceID = #{resourceid}, Content = #{content} WHERE SuggestionID = #{suggestionId}")
    void updateSuggestion(@Param("suggestionId") Integer suggestionId, @Param("resourceid") Integer resourceId, @Param("content") String content);

    // 删除建议
    @Delete("DELETE FROM suggestion WHERE SuggestionID = #{suggestionId}")
    void deleteSuggestion(@Param("suggestionId") Integer suggestionId);

    // 根据ID获取建议
    @Select("SELECT * FROM suggestion WHERE SuggestionID = #{suggestionId}")
    SuggestionDO getSuggestionById(@Param("suggestionId") Integer suggestionId);

    // 根据资源ID获取建议列表
    @Select("SELECT * FROM suggestion WHERE ResourceID = #{resourceId}")
    List<SuggestionDO> getSuggestionsByResourceId(@Param("resourceId") Integer resourceId);

    // 根据用户ID获取建议列表
    @Select("SELECT * FROM suggestion WHERE id = #{userId}")
    List<SuggestionDO> getSuggestionsByUserId(@Param("userId") Long userId);
}
